<template>
  <div>
    <AplidForm v-model="searchModel" v-bind="searchConfig" ref="searchRef" :showBtn="true" @reset="onReset" @submit="onSearch"></AplidForm>
    <el-table v-loading="loading" :data="tableData">
        <el-table-column label="区域" prop="areaName"></el-table-column>
        <el-table-column label="采集总数" prop="total"></el-table-column>
        <el-table-column label="采集成功数" prop="sucess"></el-table-column>
        <el-table-column label="采集成功率" prop="successRate"></el-table-column>
    </el-table>
  </div>
</template>

<script setup lang="ts">
import apiMod from '@/apiMod/index'

type Props = {
    dataType?:string|undefined
}
let props = withDefaults(defineProps<Props>(),{
    dataType:undefined
})
let loading = ref(false)
let searchRef = ref()
let tableData = ref([])
let searchModel = ref({})
const onReset = () => {
	searchModel.value = {}
	onSearch()
}
const onSearch = (value?,done?) =>{
    getStatistics()
    if(done){
        done()
    }
   
}
let searchConfig = {
    inline: true,
    labelPosition: 'left',
    column: [
        {
            label: '开始时间',
            prop: '',
            type: 'date',
            format:'YYYY年MM月DD日',
            valueFormat:'YYYY-MM-DD',
            span: 8,
        },
        {
            label: '结束时间',
            prop: '',
            type: 'date',
            format:'YYYY年MM月DD日',
            valueFormat:'YYYY-MM-DD',
            span: 8,
        },
    ]
}
const getStatistics = () =>{
    loading.value = true
    let params = {
        dataType:props.dataType
    }
    apiMod.view_statistics_gather(params).then(res=>{
        console.log('数据',res)
        if(res.code == 0){
            tableData.value = res.data
            loading.value = false
        }else{
            loading.value = false
        }
    })
    
   
}
onMounted(()=>{
    getStatistics()
})

</script>
<style scoped lang="scss">
</style>